package com.rc.saas.tenant.service.hlht;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.base.BaseSearch;
import com.rc.saas.tenant.mapper.hlht.HlhtOperatorSettingMapper;
import com.rc.saas.tenant.model.hlht.HlhtOperatorSetting;
import com.rc.saas.tenant.model.hlht.HlhtOperatorSettingExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HlhtOperatorSettingServiceImpl implements HlhtOperatorSettingService {

    @Autowired
    private HlhtOperatorSettingMapper hlhtOperatorSettingMapper;

    @Override
    public HlhtOperatorSettingMapper getMapper() {
        return hlhtOperatorSettingMapper;
    }

    @Override
    public PageInfo<HlhtOperatorSetting> listPageHlhtOperatorSetting(BaseSearch baseSearch) {
        PageHelper.startPage(baseSearch.getOffset(), baseSearch.getLimit());
        HlhtOperatorSettingExample example = new HlhtOperatorSettingExample();
        List<HlhtOperatorSetting> hlhtOperatorSettingList = hlhtOperatorSettingMapper.selectByExample(example);
        return new PageInfo<HlhtOperatorSetting>(hlhtOperatorSettingList);
    }

    @Override
    public HlhtOperatorSetting selectByTenantCodeAndHlhtOperatorId(String tenantCode,String hlhtOperatorId) {
        HlhtOperatorSettingExample hlhtOperatorSettingExample = new HlhtOperatorSettingExample();
        hlhtOperatorSettingExample.createCriteria().andTenantCodeEqualTo(tenantCode).andHlhtOperatorIdEqualTo(hlhtOperatorId);
        List<HlhtOperatorSetting> hlhtOperatorSettingList = hlhtOperatorSettingMapper.selectByExample(hlhtOperatorSettingExample);
        if (hlhtOperatorSettingList.size() > 0) {
            return hlhtOperatorSettingList.get(0);
        } else {
            return null;
        }
    }
}
